package com.quectel.core.module.grid.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/02/03 16:42
 */
@Data
@Schema
public class GridEventRecordDto implements Serializable {

    /**
     * ID
     */
    @Schema(description = "ID")
    private Long id;

    /**
     * 租户id
     */
    @Schema(description = "租户id")
    private Long tenantId;

    /**
     * 省编码
     */
    @Schema(description = "省编码")
    private String provinceCode;

    /**
     * 市编码
     */
    @Schema(description = "市编码")
    private String cityCode;

    /**
     * 区编码
     */
    @Schema(description = "区编码")
    private String districtCode;

    /**
     * 街道编码
     */
    @Schema(description = "街道编码")
    private String streetCode;

    /**
     * 小区id
     */
    @Schema(description = "小区id")
    private Long villageId;

    /**
     * 网格id
     */
    @Schema(description = "网格id")
    private Long gridId;

    /**
     * 网格员id
     */
    @Schema(description = "网格员id")
    private Long gridMemberId;

    /**
     * 创建级别 1省级创建2市级别3区级别4街道级别5社区级别6网格
     */
    @Schema(description = "创建级别 1省级创建2市级别3区级别4街道级别5小区级别6网格级别")
    private Byte creatorLevel;

    /**
     * 对应级别的唯一表示
     */
    @Schema(description = "对应级别的唯一表示")
    private String creatorUniqueFlag;

    /**
     * 事件当前所在层级code
     */
    @Schema(description = "事件当前所在层级code")
    private String currentCode;


    /**
     * 事件当前所在层级
     */
    @Schema(description = "事件当前所在层级")
    private Byte currentLevel;

    /**
     * 事件来源1后台创建指派2智能发现3事件上报
     */
    @Schema(description = "字典值:GridEventSource,事件来源1后台创建指派2智能发现3事件上报")
    private Byte sourceType;

    /**
     * 事件一级分类id
     */
    @Schema(description = "事件一级分类id")
    @NotNull
    private Long eventPrimaryId;

    /**
     * 事件二级分类id
     */
    @Schema(description = "事件二级分类id")
    @NotNull
    private Long eventSecondaryId;

    /**
     * 智能发现事件类型,字典值
     */
    @Schema(description = "智能发现事件类型,字典值EventType")
    private Byte aiEventType;

    /**
     * 智能事件id ai_event_record
     */
    @Schema(description = "智能事件id ai_event_record")
    private Long aiEventId;


    /**
     * 1自行上报2上报上级
     */
    @Schema(description = "1自行上报2上报上级")
    private Byte eventType;

    /**
     * 事件名称
     */
    @Schema(description = "事件名称")
    @NotEmpty
    @Length(max = 20)
    private String eventName;

    /**
     * 事件编号,系统自动生成
     */
    @Schema(description = "事件编号,系统自动生成")
    private String eventNo;

    /**
     * 事件地点
     */
    @Schema(description = "事件地点")
    @NotEmpty
    @Length(max = 80)
    private String eventAddr;

    /**
     * 事件等级:0一般1重要
     */
    @Schema(description = "字典值:GridEventLevel,事件等级:1一般2重要")
    @NotNull
    private Byte eventLevel;

    /**
     * 事件描述
     */
    @Schema(description = "事件描述")
    @NotEmpty
    private String eventDesc;

    /**
     * 事件工作内容
     */
    @Schema(description = "事件工作内容")
    private String eventDetail;

    /**
     * 事件图片json
     */
    @Schema(description = "事件图片json")
    private String eventPicturesJson;

    /**
     * 0未指派1已指派2待处理3处理中4待办结5已办结
     */
    @Schema(description = "字典值:GridEventRecordStatus")
    private Byte status;

    /**
     * 事件发生时间
     */
    @Schema(description = "事件发生时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    @NotNull
    private Date eventTime;

    /**
     * 事件完成时间
     */
    @Schema(description = "事件完成时间")
    private Date finishTime;

    /**
     * 逾期时间
     */
    @Schema(description = "逾期时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date deadline;

    /**
     * 创建人
     */
    @Schema(description = "创建人")
    private String creator;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private Date createTime;

    /**
     * 修改人
     */
    @Schema(description = "修改人")
    private String editor;

    /**
     * 修改时间
     */
    @Schema(description = "修改时间")
    private Date editTime;

    /************非数据库字段 start ************/
    @Schema(description = "网格名称")
    private String gridName;
    @Schema(description = "网格员名称")
    private String gridMemberName;
    @Schema(description = "一级事件名称")
    private String eventPrimaryName;
    @Schema(description = "二级事件名称")
    private String eventSecondaryName;
    @Schema(description = "日志list,处置条件日志筛选条件:status等于4并且seq最大的那一条")
    private List<GridEventRecordLogDto> logList;
    @Schema(description = "是否指派")
    private Byte ifAssign;
    @Schema(description = "指派单位")
    private GridRegionInfoDto assignUnit;
    @Schema(description = "自行处置结果")
    private String selfHandleResult;
    @Schema(description = "自行处置结果图片")
    private String selfHandlePicturesJson;
    /************非数据库字段 end **************/
}
